home *** CD-ROM | disk | FTP | other *** search
/ com!online 2005 May / com_0505_1.iso / opensource / top10 / amc_install.exe / {app} / Scripts / Cinéstore.ifs < prev    next >
Encoding:
Text File  |  2004-03-20  |  9.3 KB  |  274 lines

  1. // GETINFO SCRIPTING
  2. // CinΘstore (FR) import avec Affiche
  3.  
  4. (***************************************************
  5.  *  Movie importation script for:                  *
  6.  *      CinΘstore , http://www.cinestore.com       *
  7.  *                                                 *
  8.  *  crΘation le 21/08/2002 par nono.1              *
  9.  *  modifiΘ le 17/09/2002 par nono.1               *
  10.  *  modifiΘ le 14/11/2002 par nono.1               *
  11.  *  modifiΘ le 26/11/2002 par nono.1               *
  12.  *                                                 *
  13.  *  For use with Ant Movie Catalog 3.3.1           *
  14.  *  www.antp.be/software/moviecatalog              *
  15.  *                                                 *
  16.  *  This program is free software; you can         *
  17.  *  redistribute it and/or modify it under the     *
  18.  *  terms of the GNU General Public License as     *
  19.  *  published by the Free Software Foundation;     *
  20.  *  either version 2 of the License, or (at your   *
  21.  *  option) any later version.                     *
  22.  ***************************************************)
  23.  
  24. program Cinestore;
  25. var
  26.   MovieName: string;
  27.  
  28. function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
  29. var
  30.   i: Integer;
  31. begin
  32.   result := -1;
  33.   if StartAt < 0 then
  34.     StartAt := 0;
  35.   for i := StartAt to List.Count-1 do
  36.     if Pos(Pattern, List.GetString(i)) <> 0 then
  37.     begin
  38.       result := i;
  39.       Break;
  40.     end;
  41. end;
  42.  
  43. procedure AnalyzePage(Address: string);
  44. var
  45.   Page: TStringList;
  46.   LineNr: Integer;
  47. begin
  48.   Page := TStringList.Create;
  49.   Page.Text := GetPage(Address);
  50.   if pos('réponses α votre recherche', Page.Text) = 0 then
  51.   begin
  52.     SetField(fieldURL, Address);
  53.     AnalyzeMoviePage(Page);
  54.   end else
  55.   begin
  56.     PickTreeClear;
  57.     LineNr := 0;
  58.     LineNr := FindLine('href="fiche_produits.php?groupe=1&page=1&id=', Page, LineNr);
  59.     if LineNr > -1 then
  60.     begin
  61.       PickTreeAdd('Films prΘsents', '');
  62.       AddMoviesTitles(Page, LineNr);
  63.     end;
  64.     if PickTreeExec(Address) then
  65.         AnalyzePage(Address);
  66.   end;
  67.   Page.Free;
  68. end;
  69.  
  70. procedure AnalyzeMoviePage(Page: TStringList);
  71. var
  72.   Line, Value,FullValue : string;
  73.   LineNr, IntValue: Integer;
  74.   BeginPos, EndPos: Integer;
  75. begin
  76.   // Picture
  77.   LineNr := FindLine('<img src="http://a333.g.akamai.net/f/333/6918/3h/img.cinestore.com/photo/puce/', Page, 0);
  78.   if LineNr > -1 then
  79.   begin
  80.     Line := Page.GetString(LineNr);
  81.     BeginPos := pos('src="', Line)+5;
  82.     EndPos := pos('" width="50" height="70" class="aimg" border="1"', Line);
  83.     Value := copy(Line, BeginPos, EndPos - BeginPos);
  84.     GetPicture(Value, False);
  85.   end
  86.    // Translated Title
  87.   LineNr := FindLine('<b>Titre Franτais:</b>', Page, 0);
  88.   if LineNr > -1 then
  89.   begin
  90.     Line := Page.GetString(LineNr+1);
  91.     BeginPos := pos('<font color="#000000">', Line);
  92.     EndPos := pos('</font>', Line);
  93.     Value := copy(Line, BeginPos + 22, EndPos - BeginPos - 22);
  94.     HTMLRemoveTags(Value);
  95.     HTMLDecode(Value);
  96.     SetField(fieldTranslatedTitle, Value);
  97.   end;
  98.    // Original Title
  99.   LineNr := FindLine('<b>Titre Original:</b>', Page, 0);
  100.   if LineNr > -1 then
  101.   begin
  102.     Line := Page.GetString(LineNr+1);
  103.     BeginPos := pos('<font color="#000000">', Line);
  104.     EndPos := pos('</font>', Line);
  105.     Value := copy(Line, BeginPos + 22, EndPos - BeginPos - 22);
  106.     HTMLRemoveTags(Value);
  107.     HTMLDecode(Value);
  108.     SetField(fieldOriginalTitle, Value);
  109.   end;
  110.     // Description
  111.   LineNr := FindLine('histoire :</b>', Page, LineNr);
  112.   if LineNr > -1 then
  113.   begin
  114.     Line := Page.GetString(LineNr+1);
  115.     BeginPos := pos('<font color="#000000">', Line);
  116.     EndPos := pos('</font>', Line);
  117.     Value := copy(Line, BeginPos + 22, EndPos - BeginPos - 22);
  118.     HTMLRemoveTags(Value);
  119.     HTMLDecode(Value);
  120.     SetField(fieldDescription, Value);
  121.   end;
  122.   // Category
  123.   LineNr := FindLine('src="http://a333.g.akamai.net/f/333/6918/3h/img.cinestore.com/images/t/theme_1.gif"', Page, 0);
  124.   if LineNr > -1 then
  125.     begin
  126.      repeat
  127.       LineNr := LineNr+1;
  128.       Line := Page.GetString(LineNr);
  129.      until pos('</tr>', Line) > 0;
  130.      Line := Page.GetString(LineNr+2);
  131.      BeginPos := pos('color="#000000">', Line)+16;
  132.      EndPos := pos('</font></td>', Line);
  133.      Value := copy(Line, BeginPos, EndPos - BeginPos);
  134.      HTMLRemoveTags(Value);
  135.      HTMLDecode(Value);
  136.      SetField(fieldCategory, Value);
  137.     end;
  138.   // Length
  139.   LineNr := FindLine('<B>DurΘe:</b>', Page, 0);
  140.   if LineNr > -1 then
  141.     begin
  142.      Line := Page.GetString(LineNr+1);
  143.      BeginPos := pos('<font color="#000000">', Line);
  144.      EndPos := pos(' mn</font>', Line);
  145.      Value := copy(Line, BeginPos + 22, EndPos - BeginPos - 22);
  146.      HTMLRemoveTags(Value);
  147.      HTMLDecode(Value);
  148.      SetField(fieldLength, Value);
  149.     end;
  150.    // Actors
  151.     LineNr := FindLine('<b>Acteurs(s) :</b>', Page, 0);
  152.     if LineNr > -1 then
  153.     begin
  154.      FullValue := '';
  155.      Line := Page.GetString(LineNr);
  156.      repeat
  157.       BeginPos := pos('scrollbars=yes,top=0,left=0,width=330,height=400', Line);
  158.       Delete(Line, 1, BeginPos+51);
  159.       EndPos := pos('</a>', Line);
  160.       Value := copy(Line, 1, EndPos - 1);
  161.       Delete(Line, 1, EndPos+3);
  162.       if FullValue <> '' then
  163.         FullValue := FullValue + ', ';
  164.       FullValue := FullValue + Value;
  165.      until pos(' . </font>',Line) = 1;
  166.     HTMLRemoveTags(FullValue);
  167.     HTMLDecode(FullValue);
  168.     SetField(fieldActors, FullValue);
  169.     end;
  170.   // Director
  171.     LineNr := FindLine('<b>RΘalisateur(s) :</b>', Page, 0);
  172.     if LineNr > -1 then
  173.     begin
  174.      FullValue := '';
  175.      Line := Page.GetString(LineNr);
  176.      Delete(Line, 1, pos('<b>RΘalisateur(s) :</b>',Line));
  177.      repeat
  178.       BeginPos:= pos('scrollbars=yes,top=0,left=0,width=330,height=400',Line);
  179.       Delete(Line, 1, BeginPos+51);
  180.       EndPos := pos('</a>', Line);
  181.       Value := copy(Line, 1, EndPos - 1);
  182.       Delete(Line, 1, EndPos+3);
  183.       if FullValue <> '' then
  184.         FullValue := FullValue + ', ';
  185.       FullValue := FullValue + Value;
  186.      until pos(' . </font>',Line) = 1;
  187.      HTMLRemoveTags(FullValue);
  188.      HTMLDecode(FullValue);
  189.      SetField(fieldDirector, FullValue);
  190.     end;
  191.   // Year
  192.   LineNr := FindLine('<B>Date de sortie du film :</b>', Page, 0);
  193.   if LineNr > -1 then
  194.     begin
  195.      Line := Page.GetString(LineNr+1);
  196.      BeginPos := pos('</font>', Line);
  197.      Value := copy(Line, BeginPos - 4, 4);
  198.      HTMLRemoveTags(Value);
  199.      HTMLDecode(Value);
  200.      SetField(fieldYear, Value);
  201.     end;
  202.   // Commentaires
  203.   LineNr := FindLine('<B>Public :</b>', Page, 0);
  204.   if LineNr > -1 then
  205.     begin
  206.      Line := Page.GetString(LineNr+1);
  207.      BeginPos := pos('<font color="#000000">', Line);
  208.      EndPos := pos('</font>', Line);
  209.      Value := copy(Line, BeginPos + 22, EndPos - BeginPos - 22);
  210.      HTMLRemoveTags(Value);
  211.      HTMLDecode(Value);
  212.      SetField(fieldComments, Value);
  213.     end;
  214.   DisplayResults;
  215. end;
  216.  
  217. procedure AddMoviesTitles(Page: TStringList; var LineNr: Integer);
  218. var
  219.   MovieProduct,MovieTitle, MovieAddress, Line, LineProduct: string;
  220.   StartPos, EndPos, LineNRProduct: Integer;
  221. begin
  222.   LineNr := LineNr - 1;
  223.   repeat
  224.     LineNr := LineNr + 1;
  225.     LineNRProduct := LineNr;
  226.     Line := Page.GetString(LineNr);
  227.     StartPos := pos('size="1" color="#3C1A36"><b>', Line);
  228.     if StartPos > 0 then
  229.     begin
  230.       Delete(Line, 1, StartPos);
  231.       StartPos := pos('href="fiche_produits.php?groupe=1', Line);
  232.       Delete(Line, 1, StartPos);
  233.       EndPos := pos('"><font color="#3C1A36">',Line);
  234.       MovieAddress := copy(Line, 44, EndPos -44);
  235.       Delete(Line, 1, EndPos);
  236.       MovieTitle := copy(Line, 24, pos('</font></a>', Line)-24);
  237.       HTMLRemoveTags(MovieTitle);
  238.       HTMLDecode(MovieTitle);
  239.       repeat
  240.         LineNRProduct := LineNRProduct+1;
  241.         LineProduct := Page.GetString(LineNRProduct);
  242.       until (pos('<font color="#3C1A36"><b>de</b>', LineProduct) > 0) or (pos('images/i/invisible.gif" width="60%" height="1" border="0"><img',LineProduct) > 0);
  243.       if pos('images/i/invisible.gif" width="60%" height="1" border="0"><img',LineProduct) > 0 then
  244.       begin
  245.         MovieProduct := '';
  246.       end else
  247.       begin
  248.         StartPos := pos('left=0,width=330,height=400',LineProduct);
  249.         Delete(LineProduct,1,StartPos+30);
  250.         MovieProduct :=copy(LineProduct, 1,pos('</a></font>',LineProduct)-1);
  251.         HTMLRemoveTags(MovieProduct);
  252.         HTMLDecode(MovieProduct);
  253.         MovieProduct := ' (de ' + MovieProduct + ')';
  254.       end;
  255.       PickTreeAdd(MovieTitle+MovieProduct, 'http://www.cinestore.com/html/fiche_produits.php?groupe=1&page=2&id='+MovieAddress);
  256.     end;
  257.   until pos('<font color="#3C1A36">[1]</font>', Line) > 0;
  258. end;
  259.  
  260. begin
  261.   if CheckVersion(3,4,0) then
  262.   begin
  263.     MovieName := GetField(fieldTranslatedTitle);
  264.     if MovieName = '' then
  265.       MovieName := GetField(fieldOriginalTitle);
  266.     if Input('Importation de CinΘstore.com', 'Entrer le titre du film:', MovieName) then
  267.     begin
  268.       AnalyzePage('http://www.cinestore.com/html/liste_mixte.php?CINESTORE=1a5694f56f546666f7761a537b867798&recstr='+UrlEncode(MovieName)+'&grprec=1&type=recherche&id_partenaire=1&x=7&y=8');
  269.     end;
  270.   end else
  271.     ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.4.0)');
  272. end.
  273.  
  274.